package com.spring.app.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.spring.app.dao.ItemRepository;
import com.spring.app.domain.ItemData;

@Service
public class ProductsService {
	
	@Autowired
	private ItemRepository itemRepository;
	
	public ItemData save(ItemData item) {
		return itemRepository.save(item);
		
	}
	
	public List<ItemData> getItemDataList() {
		return itemRepository.findAll();
		
	}
	
	public void deleteItem(Long itemId) {
		 itemRepository.delete(itemId);
	}
	
	public List<ItemData> getSearchItemsbyKeyword(String searchKey) {
		return itemRepository.findByItems(searchKey);
		
	}

}
